package org.pi.common.plot.axes
import org.pi.common.plot.drawables._

/** debug class */
class AxesCanvas(var axes: Axes) extends java.awt.Canvas {
  override def paint(g1: java.awt.Graphics) {
    val g2 = g1.asInstanceOf[java.awt.Graphics2D]
    axes.paint(g2);
  }
}

object AxesCanvas {
  def apply(axes: Axes) {
    val canvas = new AxesCanvas(axes);
    val f = new java.awt.Frame();
    f.add(canvas)
    f.addWindowListener(new java.awt.event.WindowAdapter{
      override def windowClosing(event: java.awt.event.WindowEvent) {
        f.dispose()
      }
    })
    f.setSize(400,300)
    f.setVisible(true)
  }

  def main(arsg: Array[String]) {
    println("start AxisCanvasDemo")
    val axes = new SimpleAxes()
    axes.addDrawable( new Line(20,10,80,30) )
    axes.addDrawable( new Line(120,50,90,20) )
    AxesCanvas( axes )
    println("end AxisCanvasDemo")
  }
}